import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import myindex from '@/components/myindex'
import indexs from '@/components/indexs'
import myreg from '@/components/myreg'
import mylogin from '@/components/mylogin'
import mylogin_two from '@/components/mylogin_two'
import up_password from '@/components/up_password'
import user_show from '@/components/user_show'
import myhome from '@/components/myhome'


Vue.use(Router)

var routes = [
        {
          path:'/',
          name:'index',
          component:index
        },
        {
          path:'/myindex',
          name:'myindex',
          component:myindex
        },
        {
          path:'/indexs',
          name:'indexs',
          component:indexs
        },
        {
          path:'/myreg',
          name:'myreg',
          component:myreg
        },
        {
          path:'/mylogin',
          name:'mylogin',
          component:mylogin
        },
        {
          path:'/mylogin_two',
          name:'mylogin_two',
          component:mylogin_two
        },
        {
          path:'/alter',
          name:'up_password',
          component:up_password
        },
        {
          path:'/user_show',
          name:'user_show',
          component:user_show
        },
        {
          path:'/myhome',
          name:'myhome',
          component:myhome,
          beforeEnter: (to, from, next) => {
            // to  去哪里
            // from  来自哪里
            // next  下一步
            if (localStorage.getItem('username')){
              console.log("已经登录")
              next()
            }else{
              next('/mylogin_two')
            }
          }
        },
        
]

export default new Router({
  routes:routes,
  mode:'history'   /*hash*/
})
